package com.summer.common.file;

import com.summer.common.FileConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author likun
 * 2018/3/15 11:29
 * 获取FileSystem
 **/
@Component
public class FileSystemFactory {

    private volatile static FileSystem fileSystem;

    @Autowired
    private FileConfig fileConfig;

    /**
     * 获取FileSystem
     *
     * @return
     */
    public FileSystem getFileSystem() {
        if (fileSystem == null) {
            switch (fileConfig.getFileSystem()) {
                case 0:
                    fileSystem = new NativeFileSystem();
            }
        }
        return fileSystem;
    }
}
